//
//  UIImageView+WebImage.swift
//  WeiBoApp
//
//  Created by James on 2017/7/18.
//  Copyright © 2017年 James. All rights reserved.
//

import SDWebImage

extension UIImageView {
    
    
    /// 隔离 SDWebImage 设置图像函数
    ///
    /// - Parameters:
    ///   - urlString: urlstr
    ///   - placeholdImage: 占位图
    func hzj_setImage(urlString:String,placeholdImage:UIImage?,isAvatar:Bool = false)  {
        guard let url = URL(string: urlString) else {
            image = placeholdImage
            return
        }
        
        sd_setImage(with: url, placeholderImage: placeholdImage, options: [], progress: nil, completed: {(image,_,_,_)in
            //完成回调 对头像图像进行处理
            if isAvatar {
                self.image = image?.hzj_avatarImage(size: self.bounds.size)
            }
        })
        
    }
}
